import {
  IsInt,
  IsBoolean,
  IsDate,
  Length
} from "class-validator";
  
import { Column, Entity, OneToMany, OneToOne, PrimaryColumn, JoinColumn,PrimaryGeneratedColumn } from "typeorm";
import { Good } from "@src/apps/goods/entities/good.entity"
import { Bec } from "@src/apps/goods/entities/bec.entity"

export const MAX_IP_LENGTH = 64;
export const MAX_STACK_LENGTH = 6;
export const MAX_MAC_LENGTH = 48;

@Entity("good_power")
export class Power {
  @PrimaryGeneratedColumn()
  id: number;

  @Column("int")
  @IsInt()
  runNo: number;

  @Column("varchar", { length: MAX_MAC_LENGTH })
  @Length(7,MAX_MAC_LENGTH)
  mac: string;
  
  @Column("varchar", { length: MAX_IP_LENGTH })
  @Length(7,MAX_IP_LENGTH)
  ip: string;

  @Column("varchar", { length: MAX_STACK_LENGTH })
  @Length(1,MAX_STACK_LENGTH)
  stack: string
  
  @Column("varchar")
  @Length(7,MAX_IP_LENGTH)
  tempip: string;

  @OneToMany(()=>Good, good=>good.power)
  gcus: Good[];

  @OneToOne(()=>Bec)
  bec: Bec;
}